var setChildArr = new Array()
setChildArr[1] = ["true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,如果是fmp4建议设为true,默认false"]
setChildArr[2] = ["是否开启data channel,默认true"]

var arr = new Array()
arr[1] = ['false', 'ture',]
arr[2] = ['true', 'false',]

// 第二个 selector 动态插入数据
// 置空 select 的子节点
function removeChild() {
  var child = document.querySelector('#child')
  var c_length = child.options.length
  if(c_length > 0) {
      for(var i = 0; i < c_length; i++){
          child.options.remove(0)
      }
  }
}

// 插入数据到 select 的 option 节点
function addOption(val, txt) {
    var child = document.querySelector('#child')
    var opt = document.createElement("option")
    opt.text = txt
    opt.value = val
    child.options.add(opt)
}

// 循环把数组值插入到 option 中
function clickOpt() {
    var parent = document.querySelector('#parent')
    var p_value = parent.value;
    var p = parseInt(p_value)
    var child = document.querySelector('#child')
    var c_length = child.options.length
    if(c_length > 0) {
        for (var i = 0; i < c_length; i++) {
            child.options.remove(0)
        }
    }
    if(p_value == '1') {
      removeChild()
      parent.title = setChildArr[p]
        for(var i = 0; i < arr[1].length; i++) {
          console.log('show')
            addOption(i, arr[1][i])
        }
    } else if(p_value == '2'){
      removeChild()
      parent.title = setChildArr[p]
        for(var i = 0; i < arr[2].length; i++) {
            addOption(i, arr[2][i])
        }
    }
}


// <!-- chunkSize: 512*1024,        //每个chunk的大小,必须是32K的整数倍,默认1M
// urgent: 2,                  //urgent的块数,默认2
// normal: 3,                  //normal的块数,默认3
// prefetch: 2,                //prefetch(用data channel下载)的块数,默认3
// interval: 5000,             //滑动窗口的时间间隔,单位毫秒,默认10s
// auto: false,                //true为连续下载buffer,false则是只有当前播放时间与已缓冲时间小于slideInterval时下载buffer,如果是fmp4建议设为true,默认false
// timeout: 5000,              //连接data channel的超时时间,单位毫秒,默认5s
// reconnectTimes: 0,          //超时重连次数,默认0次(未实现)
// slideInterval: 10,          //当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s
// useDataChannel: true,       //是否开启data channel,默认true -->
var setitle = new Array()
setitle[1] = ["每个chunk的大小,必须是32K的整数倍,默认1M"]
setitle[5] = ["滑动窗口的时间间隔,单位毫秒,默认10s"]
setitle[6] = ["连接data channel的超时时间,单位毫秒,默认5s"]
setitle[7] = ["超时重连次数,默认0次(未实现)"]
setitle[8] = ["当前播放时间与已缓冲时间小于这个数值时触发窗口滑动,单位秒,默认20s"]

var setarr = new Array()
setarr[1] = ['1M']
setarr[5] = ['5000']
setarr[6] = ['5000']
setarr[7] = ['0']
setarr[8] = ['20']

var FirstaidSetarr = new Array()
FirstaidSetarr[1] = ['2']
FirstaidSetarr[2] = ['3']
FirstaidSetarr[3] = ['2']

var Firstaidsetitle = new Array()
Firstaidsetitle[1] = ["urgent的块数,默认2"]
Firstaidsetitle[2] = ["normal的块数,默认3"]
Firstaidsetitle[3] = ["prefetch(用data channel下载)的块数,默认3"]

 // 置空 select 子节点
var removeInput = function() {
  var inputBtn = document.querySelector('#setChild')
  inputBtn.values = ''
}

var setchild = document.querySelector('#setChild')

// 第一个 selector 动态插入数据
function setInputValue() {
  console.log('invalue___')
    var parent = document.querySelector('#setParent')
    var p_value = parent.value;
    var child = document.querySelector('#setChild')
    if(p_value == '1') {
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '2'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '3'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '4'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '5'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '6'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '7'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    } else if(p_value == '8'){
      removeInput()
      console.log('value_p', p_value)
      var p = parseInt(p_value)
      setchild.value = setarr[p]
      parent.title = setitle[p]
    }
}


// 置空 Fistaid 算法子选项
var removeFirstaidInput = function() {
  var inputBtn = document.querySelector('#Firstaid-setChild')
  inputBtn.values = ''
}
// Fistaid 算法设置
function setFirstaidSetarr() {
  var Firstaidparent = document.querySelector('#Firstaid-setParent')
  // console.log('Id', Firstaidparent)
  var Firstaidvalue = Firstaidparent.value;
  var Firstaidsetchild = document.querySelector('#Firstaid-setChild')
  if(Firstaidvalue == '1') {
    removeFirstaidInput()
    console.log('value_p', Firstaidvalue)
    var p = parseInt(Firstaidvalue)
    Firstaidsetchild.value = FirstaidSetarr[p]
    Firstaidparent.title = Firstaidsetitle[p]
  } else if(Firstaidvalue == '2'){
    removeFirstaidInput()
    var p = parseInt(Firstaidvalue)
    Firstaidsetchild.value = FirstaidSetarr[p]
    Firstaidparent.title = Firstaidsetitle[p]
  } else if (Firstaidvalue == '3') {
    removeFirstaidInput()
    var p = parseInt(Firstaidvalue)
    Firstaidsetchild.value = FirstaidSetarr[p]
    Firstaidparent.title = Firstaidsetitle[p]
  }
}


// var jqueryFunction = function() {
//   var attr = $("#setParent").value
//   console.log('jqueyr vlaue', attr)
// }
